#ifndef __glRenderer__h__included__
#define __glRenderer__h__included__

#include "iRenderer.h"

#include "neiderra/core/Core.h"

#include "Image.h"
// #include "Scene.h"
#include "iRenderTarget.h"
#include "Texture.h"
#include "Alphabet.h"

#include <map>

//using namespace neiderra::core;
//using namespace neiderra::core::gui;

using neiderra::gui::GUIWindowImpl;
using neiderra::gui::GUIWindow;
using namespace neiderra::types;
// using neiderra::scene::aScene;
using neiderra::rendering::Texture;
using neiderra::rendering::Alphabet;

namespace neiderra { 
	namespace rendering {

		//! OpenGL iRenderer implementation
		class glRenderer: public iRenderer
		{
		public:
			glRenderer(Core*);
			virtual ~glRenderer();
		
			virtual void rotatef(float angle, vec3&);
			virtual void rotatef(float angle, float x, float y, float z);
			virtual void translatef(vec3&);
			virtual void translatef(float x, float y, float z);
			virtual void scalef(float x, float y, float z) ;
			virtual void scalef(vec3&);
		
			virtual void pushMatrix();
			virtual void popMatrix();
			virtual void multMatrix(float *m);
			virtual void identity();
		
			virtual void init(iRenderTarget* impl);
		
			virtual void render(sg::sgNode*);
			virtual void render(sg::sgDOFTranslateNode*);
			virtual void render(sg::sgDOFRotateNode*);
			virtual void render(sg::sgDOFScaleNode*);
			virtual void render(sg::sgStringNode*);
			virtual void render(sg::sgDOFNode*);
			virtual void render(sg::sgParticleSystemNode*);
		
			virtual void render(vec3& vec);
		
// 			virtual void render(aSceneObject*);
			virtual void render(Alphabet*);
			virtual void render(RenderingObject*);
			virtual void render(Mesh*, Texture*);
			virtual void render(Image*, unsigned x, unsigned y);
// 			virtual void render(aScene*);
			virtual void render(TextString*, unsigned x, unsigned y);
			virtual void render(Sprite*);
			virtual void render(PolyParticleSystem*);
			virtual void render(ParticleSystem*);
			// Renders root node and it's children
			virtual void RenderRoot();
		
			virtual float getFPS();
		
			// Provides visualization
			virtual void update(double deltaT);
		
			virtual iRenderTarget* getTarget();
		
			virtual void showAxes() { _showAxes = true; }
			virtual void hideAxes() { _showAxes = false; }
			
		protected:
			virtual void setPerspectiveMode();
			virtual void setOrthoMode();
		
		public:
			virtual void renderTexture(Texture* texture);
		
		private:
			void drawAxes();
			
			bool _showAxes;
			unsigned _frameCount;
		};
	}
}

#endif
